package com.entity

import com.jcraft.jsch.SftpProgressMonitor
import java.text.DecimalFormat

class MyProgressMonitor(private val total: Long) : SftpProgressMonitor {

    private var transfered: Long = 0
    override fun init(i: Int, s: String, s1: String, l: Long) {
//        System.out.println("开始上传!");
    }

    override fun count(l: Long): Boolean {
        transfered += l
        if (total == 0L) {
            print("\r")
            print("%n% 上传进度: 未知 （$transfered）")
        } else {
            val d = transfered.toDouble() * 100 / total.toDouble()
            val df = DecimalFormat("#.##")
            print("\r")
            print("%n% 上传进度: " + df.format(d) + "%")
        }
        return true
    }

    override fun end() {
//        System.out.println("");
//        System.out.println("上传完成!");
    }

}
